package com.hualan.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.mapper.ConsultCommentMapper;
import com.hualan.pojo.ConsultComment;
import com.hualan.service.ConsultConmmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConsultConmmentServiceimpl implements ConsultConmmentService {
    @Autowired
    private ConsultCommentMapper consultCommentMapper;

    @Override
    public List<ConsultComment> getCommentDetails() {
        // 调用Mapper中的方法获取评论详情，用对象接受，并判断是否为空，不为空则输出到控制台
        List<ConsultComment> consultComment = consultCommentMapper.selectCommentDetails();
        if (consultComment != null) {
            System.out.println("成功获取评论详情");
        }



        return consultCommentMapper.selectCommentDetails();
    }
    //分页模糊查询
    @Override
    public PageInfo<ConsultComment> selectAllPage(Integer pageNum, Integer pageSize, String evaluationContent) {
        //设计分页参数
        PageHelper.startPage(pageNum, pageSize);
        //调用Mapper方法查询数据
        List<ConsultComment> consultCommentList = consultCommentMapper.selectAllPage( evaluationContent);
        //返回分页结果
        return new  PageInfo<>(consultCommentList);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return consultCommentMapper.deleteByPrimaryKey(id);
    }


    // 批量删除
    @Override
    public int deleteBatch(List<Long> ids) {
        return consultCommentMapper.deleteBatch(ids);
    }


    //逻辑删除
    @Override
    public int deleteLogic(Long id) {
        return consultCommentMapper.deleteLogic(id);
    }
}
